package com.fan.play.ui.activity

import android.os.Bundle
import android.os.MessageQueue
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import com.fan.play.databinding.ActivityMainBinding
import com.fan.play.ui.adapter.CaptureAdapter
import com.fan.play.utils.LogUtil

class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    private var mCaptureList = mutableListOf("0")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.btnPreview.setOnClickListener { view ->
            binding.btnPreview.isActivated = !binding.btnPreview.isActivated
        }

        binding.btnRecord.setOnClickListener {
            binding.btnRecord.isActivated = !binding.btnRecord.isActivated
        }

        binding.btnPublish.setOnClickListener {
            binding.btnPublish.isActivated = !binding.btnPublish.isActivated
        }

        val moduleAdapter = CaptureAdapter()
        binding.recyclerView.adapter = moduleAdapter;
        binding.recyclerView.layoutManager = GridLayoutManager(this, mCaptureList.size)

        moduleAdapter.setOnItemClickListener { adapter, view, position ->
            LogUtil.logInfo("${position}--${view.isActivated}")
        }
        moduleAdapter.setNewInstance(mCaptureList)
    }



}